<?php
class Zendvn_System_Plugin extends Zend_Controller_Plugin_Abstract
{    
	   
	public function preDispatch(Zend_Controller_Request_Abstract $request){
      	$info = new Zendvn_System_Info();
        $group_id = $info->getMemberInfo('group_id');
        
        $ss = new Zend_Session_Namespace(APPLICATION_KEY);
        
        if($request->getModuleName() == 'admin'){
            if($ss->type == 'Guest' || $group_id == 4){
                $request->setModuleName('default');
                $request->setControllerName('index');
                $request->setActionName('index');
            }else{                
//                $acl = $info->getAclInfo();
//                $group = $info->getGroupInfo('name');
//                
//                $module = $request->getModuleName();
//                $controller = $request->getControllerName();
//                $action = $request->getActionName();			
//                $accessArea = $module . '-' . $controller . '-' . $action;
//                
//                if(!$acl->isAllowed($group,null,$accessArea)){
//                    $request->setModuleName('admin');
//                    $request->setControllerName('index');
//                    $request->setActionName('noaccess');
//                }
            }
        }
    }
    
	
}